<template>
  <div class="fangan_table">
    <el-table class="fangan_list_table" :data="state.chemelist" style="width: 100%" height="100%">
      <el-table-column prop="date" label="方案编码">
        <template #default="scope">
          <div>{{ scope.row.scheme_code }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="date" label="方案名称">
        <template #default="scope">
          <div>{{ state.activetabs == 0 ? scope.row.scheme_name : scope.row.task_name }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="name" label="保存时间">
        <template #default="scope">
          <div>{{ scope.row.update_time }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="name" label="状态" width="150">
        <template #default="scope">
          <el-switch v-model="scope.row.status" @change="store.changestatus(scope.row)"
            style="--el-switch-on-color: var(--pcmain-color); --el-switch-off-color: #bfbfbf; width: 48px; height: 24px"
            :active-value="1" :inactive-value="0" />
        </template>
      </el-table-column>
      <el-table-column prop="address" label="操作" width="100">
        <template #default="scope">
          <div style="display: flex">
            <div style="color: var(--pcmain-color); cursor: pointer" @click="openeditfanan(scope.row)">编辑</div>
            <div style="margin-left: 16px; color: #fb445f; cursor: pointer" @click="store.deletefanan(scope.row)">
              删除
            </div>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
const { store, state } = inject('Fanan')

const router = useRouter()
const openeditfanan = (row) => {
  if (state.activetabs == 0) {
    router.replace(`scheme?scheme_code=${row.scheme_code}`)
  } else {
    router.replace(`schemeGendan?scheme_code=${row.scheme_code}`)
  }
  
}
</script>

<style lang="scss" scoped>
.fangan_table {
  padding: 16px 16px 0 16px;
}
</style>

<style>
.fangan_list_table.el-table th.el-table__cell {
  height: 48px;
}

.fangan_list_table.el-table th.el-table__cell .cell {
  font-size: 14px;
  font-weight: 600;
  color: #8a8a8a;
}

.fangan_list_table.el-table td.el-table__cell {
  padding: 12px 0;
}

.fangan_list_table.el-table td.el-table__cell .cell {
  font-size: 14px;
  color: #333;
}
</style>